//
//  UIImage+extension.swift
//  WeiboClassSix
//
//  Created by HM on 16/10/6.
//  Copyright © 2016年 HM. All rights reserved.
//

import UIKit

extension UIImage {
    class func createImage(size: CGSize = CGSize(width: 1, height: 1), color: UIColor = UIColor.white) -> UIImage {
        //1. 开启上下文
        UIGraphicsBeginImageContext(size)
        
        //2. 设置填充颜色
        color.setFill()
        
        //3. 颜色填充
        let rect = CGRect(origin: CGPoint.zero, size: size)
        UIRectFill(rect)
        
        //4. 获取图片
        let image = UIGraphicsGetImageFromCurrentImageContext()
        
        //5. 关闭上下文
        UIGraphicsEndImageContext()
        
        return image!
    }
}
